<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>所有图书信息</title>
    <link href="/css/index.css" rel="stylesheet" type="text/css" >
    <link href="/css/right.css" rel="stylesheet" type="text/css" >
</head>
<body>
<div class="men">
    <div class="main_top">
        <?php include 'top.php'?>
    </div>
    <div class="main_center">
        <div class="main_center_left">
            <?php include 'left.php'?>
        </div>
        <div class="main_center_right">
            <form action="/action/searchBookAction.php" method="post">
                <div class="main">
                    <div class="center">
                        <div class="shousuo">
                            <span>图书名称：</span>
                            <input type="text" name="bookName">
                            <input type="submit" value="搜索">
                        </div>
                    </div>
                    <div class="right">
                        <ul class="biaoti">
                            <li>图书编号</li>
                            <li>图书名称</li>
                            <li>出版社</li>
                            <li>价格</li>
                            <li>借阅状态</li>
                            <li>操作</li>
                        </ul>
                        <?php
                        //连接数据库
                        try {
                            $db = new PDO('mysql:dbname=books;host=127.0.0.1','root','123456');
                            $result= $db->query('select * from book');
                            $re=$result->fetchAll();
                            if($re){
                                foreach($re as $list){?>
                                    <ul class="shuju">
                                        <li><?="$list[bookid]"; ?></li>
                                        <li><?="$list[bookName]"; ?></li>
                                        <li><?="$list[press]";?></li>
                                        <li><?="$list[price]";?></li>
                                        <li><?php
                                            if("$list[status]" ==1){
                                                echo "<span>已借阅</span>";
                                            }else{
                                                echo "<span>未借阅</span>";
                                            }
                                            ?>
                                        </li>
                                        <li>
                                            <a href="#">修改</a>
                                            <a href="#">删除</a>
                                        </li>
                                        <div style="clear: both;"></div>
                                    </ul>
                                    <?php
                                }
                            }else{
                                echo "<script> alert('查询失败!'); location.href='../html/bookQuery.php';</script>";
                            }

                        } catch (PDOException $e) {
                            echo 'Connection failed';
                        }
                        ?>
                    </div>
                </div>
            </form>
        </div>
        <div style="clear: both;"></div>
    </div>
</div>

</body>
</html>